repo: Support fsync=false configuration
authorColin Walters <walters@verbum.org>
Wed, 4 Jun 2014 13:59:47 +0000 (09:59 -0400)
committerColin Walters <walters@verbum.org>
Thu, 5 Jun 2014 21:35:50 +0000 (17:35 -0400)
See rationale in the updated docs.  Basically developer use cases as
well as UPS-backed servers.

doc/ostree.repo-config.xml
src/libostree/ostree-repo.c

index d2f65421f71f6363bdbb1b23a6780aeac17a3c3c..621879c978711487efb786d7bb664b98859c7084 100644 (file)
@@ -83,6 +83,30 @@ Boston, MA 02111-1307, USA.
         <term><varname>repo_version</varname></term>
         <listitem><para>Currently, this must be set to <literal>1</literal>.</para></listitem>
       </varlistentry>
+
+      <varlistentry>
+        <term><varname>fsync</varname></term>
+        <listitem><para>Boolean value controlling whether or not to
+        ensure files are on stable storage when performing operations
+        such as commits, pulls, and checkouts.  Defaults to
+        <literal>true</literal>.</para>
+       <para>
+         If you disable fsync, OSTree will no longer be robust
+         against kernel crashes or power loss.
+       </para>
+       <para>
+         You might choose to disable this for local development
+         repositories, under the assumption they can be recreated from
+         source.  Similarly, you could disable for a mirror where you could
+         re-pull.
+       </para>
+       <para>
+         For the system repository, you might choose to disable fsync
+         if you have uninterruptable power supplies and a well tested
+         kernel.
+       </para>
+       </listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
 
index 210ce36620eff531066aec63cee829e2173f5e72..aa2bd2df1d24c0f2247128deb8327ceda9da2b4b 100644 (file)
@@ -682,6 +682,17 @@ ostree_repo_open (OstreeRepo    *self,
                                             TRUE, &self->enable_uncompressed_cache, error))
     goto out;
 
+  {
+    gboolean do_fsync;
+    
+    if (!ot_keyfile_get_boolean_with_default (self->config, "core", "fsync",
+                                              TRUE, &do_fsync, error))
+      goto out;
+    
+    if (!do_fsync)
+      ostree_repo_set_disable_fsync (self, TRUE);
+  }
+
   {
     gs_unref_object GFile *default_repo_path = get_default_repo_path ();